package com.keyin.protocol;

import org.json.JSONObject;

import com.keyin.android.util.ReflectionFactory;

public class JsonHelper {

	public static JsonBean parse(String json, Class<?> c) throws Exception {
		JSONObject jsonObj = new JSONObject(json);
		
		JsonBean obj = (JsonBean) ReflectionFactory.create(jsonObj, c);
		try {
			(obj).parse(jsonObj.getJSONObject("result"));
		} catch (Exception e) {
			throw new JsonResultException(
					jsonObj.getString("json string has some exception"));
		}
		return obj;
	}
}
